﻿<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true"
    CodeFile="Prescription.aspx.cs" Inherits="Admin_Default" Title="" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

    <script>
        var Rows = 1;
        function DeleteRow(obj) {
            $(obj).closest("tr").fadeOut(1000, function() {
                $(obj).closest("tr").find("td").eq(4).text("Deleted");
                $("#<%=Button1.ClientID%>").val("Testing");
                $(obj).closest("tr").find("td").eq(11).find("input").eq(0).val("Testing");
                $(obj).closest("tr").find("td").eq(11).find("input:hidden").eq(0).val("Testing" + Rows);
                Rows = Rows + 1;
            });
        }
        function Undo() {
            Rows = Rows - 1;
            var hf = $("#<%=GridView1.ClientID%>").find('input:hidden[value="Testing' + Rows + '"]');
            $(hf).closest("tr").fadeIn(1000);
        }
    </script>

    <data:GridViewSearchPanel ID="GridViewSearchPanel1" runat="server" GridViewControlID="GridView1"
        PersistenceMethod="Session">
    </data:GridViewSearchPanel>
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
        PageSize="5" DataKeyNames="PrescriptionID" DataSourceID="PrescriptionDataSource1"
        BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" OnRowCommand="GridView1_RowCommand">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <a href="#<%#Eval("PrescriptionId") %>" onclick="DeleteRow(this);">Delete</a>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:HyperLinkField DataNavigateUrlFormatString="PrescriptionEdit.aspx?PrescriptionID={0}"
                DataNavigateUrlFields="PrescriptionID" Text="Select" />
            <asp:BoundField DataField="CreateDate" DataFormatString="{0:dd-MMM-yyyy}" HtmlEncode="False"
                HeaderText="Create Date" SortExpression="[CreateDate]" />
            <asp:BoundField DataField="PrescriptionId" HeaderText="Prescription Id" SortExpression="[PrescriptionID]"
                ReadOnly="True" />
            <asp:BoundField DataField="PatientCode" HeaderText="Patient Code" SortExpression="[PatientCode]" />
            <asp:BoundField DataField="PatientName" HeaderText="Patient Name" SortExpression="[PatientName]" />
            <asp:BoundField DataField="DeliveryDate" DataFormatString="{0:dd-MMM-yyyy}" HtmlEncode="False"
                HeaderText="Delivery Date" SortExpression="[DeliveryDate]" />
            <asp:BoundField DataField="Address" HeaderText="Address" SortExpression="[Address]" />
            <asp:BoundField DataField="Amount" HeaderText="Amount" SortExpression="[Amount]" />
            <asp:BoundField DataField="SalesPerson" HeaderText="Sales Person" SortExpression="[SalesPerson]"/>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:ImageButton ID="btn_Delete" runat="server" CommandName="CustomDelete" CommandArgument='<%#Eval("PrescriptionID") %>'
                        ImageUrl="~/Admin/resources/images/icons/cross_circle.png" OnClientClick="return confirm('Are you sure want to delete?');" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:HiddenField runat="server" ID="testHF" Value="H" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
        <FooterStyle BackColor="White" ForeColor="#000066" />
        <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
        <PagerSettings FirstPageText="« First" LastPageText="Last »" NextPageText="Next »"
            PreviousPageText="« Previous" Mode="NumericFirstLast" PageButtonCount="4"></PagerSettings>
        <PagerStyle CssClass="pagination" HorizontalAlign="Right" BackColor="White" ForeColor="#000066" />
        <RowStyle ForeColor="#000066" />
    </asp:GridView>
    <data:PrescriptionDataSource ID="PrescriptionDataSource1" runat="server" SelectMethod="GetPaged"
        EnablePaging="True" EnableSorting="True" EnableDeepLoad="True">
        <DeepLoadProperties Method="IncludeChildren" Recursive="False">
            <Types>
                <data:PrescriptionProperty Name="WebUser" />
                <%--<data:PrescriptionProperty Name="PrescriptionVoid" />--%>
                <%--<data:PrescriptionProperty Name="PrescriptionDetailCollection" />--%>
            </Types>
        </DeepLoadProperties>
        <Parameters>
            <data:CustomParameter Name="WhereClause" Value="" ConvertEmptyStringToNull="false" />
            <data:CustomParameter Name="OrderByClause" Value="" ConvertEmptyStringToNull="false" />
            <asp:ControlParameter Name="PageIndex" ControlID="GridView1" PropertyName="PageIndex"
                Type="Int32" />
            <asp:ControlParameter Name="PageSize" ControlID="GridView1" PropertyName="PageSize"
                Type="Int32" />
            <data:CustomParameter Name="RecordCount" Value="0" Type="Int32" />
        </Parameters>
    </data:PrescriptionDataSource>
    <br />
    <br />
    <br />
    <br />
    <asp:Button ID="btnPrescription" runat="server" OnClientClick="javascript:location.href='PrescriptionEdit.aspx'; return false;"
        Text="Add New" />
    <asp:Button runat="server" ID="Button2" Text="Test" OnClick="Button1_Click"></asp:Button>
    <asp:Button runat="server" ID="Button1" Text="Test" OnClientClick="return Undo();">
    </asp:Button>
    <input type="button" onclick="Undo();" value="Input" />
</asp:Content>
